package org.example.util;

import org.springframework.util.CollectionUtils;

import java.util.*;

/**
 * @author huangshen
 * @version 0.0.3
 * @description ObjectUtil
 * @since 2022/1/24 14:23
 */
public class ObjectUtils {

    public static Map<Integer, String> sortMapByKey(Map<Integer, String> map) {
        if (CollectionUtils.isEmpty(map)) {
            return Collections.emptyMap();
        }
        //treeMap适用于按自然顺序或自定义顺序遍历键(key)
        Map<Integer, String> treeMap = new TreeMap<>(new MapKeyComparator());
        treeMap.putAll(map);
        return treeMap;
    }


    public static Boolean isEquals(Object object1, Object object2){
        return object1 == object2 && (object1.hashCode() == object2.hashCode());
    }
}
